import router from "@/router/index";
import store from "@/store";
// 路由守卫
//白名单
const whiteList = ['/adminlogin','/apply','/index','/login','/notice','/onepost']
//管理员
const AdminList = ['/','/teacher','/student','/practise','/examplace','/practisestatus','/appointmentstatus','/forum','/sender','/evaluation','/recruitment']
//教练
const CoachList = ['/carstudent','/carpractise','/examstatus']
//学员
const StudentList = ['/findcoach','/carpractises','/carexam','/mystatus']
router.beforeEach((to,form,next)=>{
    if(store.getters.Type === '管理员'){
        if (StudentList.includes(to.path)||CoachList.includes(to.path)||to.path==='/information'||to.path==='/adminlogin'){
            next('/')
        }else {
            next()
        }
    }else if(store.getters.Type === '教练'){
        if (AdminList.includes(to.path)||StudentList.includes(to.path)){
            next('/index')
        }else if (to.path==='/adminlogin'){
            next('/index')
        }else {
            next()
        }
    }else if (store.getters.Type === '学员'){
        if (AdminList.includes(to.path)||CoachList.includes(to.path)){
            next('/index')
        }else if (to.path==='/adminlogin'){
            next('/index')
        }else {
            next()
        }
    }else {
        if(whiteList.includes(to.path)){
            next()
        }else {
            next('/index')
        }
    }
})
